package pers.course.week9;

import java.util.*;

public class DifferentStone {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String J = in.next();
        String S = in.next();
        char[] j = J.toCharArray();
        char[] s = S.toCharArray();
        int count = 0;
        for (char jj : j) {
            for (char ss : s) {
                if (jj == ss)
                    count++;
            }
        }
        System.out.println(count);
    }
}
